#!/usr/bin/python
import cgitb
cgitb.enable()

import cgi ,time,os,urllib

def get_present_time():
	idata = time.localtime()
	i_time = "now is : %d / %d / %d  %d:%d:%d <P>" %(idata[0],idata[1],idata[2],idata[3],idata[4],idata[5])
	return i_time

 
username = "qingluan"
def authentication(username_in):
	if username == username_in:
		print "ok right <P>"
		return 1
	else :
		print "try again: <P>"
		return 0


print "Content-type: text/html"
print

print """
<HTML>
<HEAD>
<TITLE>My Cgi Programer</TITLE></HEAD>
<BODY>"""

print "%s" % get_present_time()

form = cgi.FieldStorage()

if  form.getfirst('username') == None:
	print "no username <P>"
else:
	if authentication(cgi.escape(form.getfirst('username'))):

		print '<A HERF="%s?username=%s"><TT>%s</TT></A><P>' % \
			(os.environ['SCRIPT_NAME'],
			urllib.quote_plus(form.getfirst('username')),
			cgi.escape(form.getfirst('username')))
	else:
		pass

		
print """
<FORM METHOD="GET" ACTION="%s">
Supply some username: 
<INPUT TYPE="text" NAME="username" WIDTH="40">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM></BODY></HTML>""" % os.environ['SCRIPT_NAME']